/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Desktop_MainOut.java
 *
 * Created on Mar 31, 2011, 5:10:55 PM
 */
package DesktopGUIpackage;

import Controller.DesktopController;
import Controller.DesktopControllerHelper;
import DTO.Item;
import Session.SessionManager;
import Utilities.MoneyFormatter;
import java.awt.Graphics;
import java.util.List;
import javax.swing.JPanel;

/**
 *
 * @author edaype
 */
public class Desktop_MainOut extends javax.swing.JPanel {

    private DesktopController desktopController = null;
    private DesktopControllerHelper desktopControllerHelper = null;
    private SessionManager mgr = null;
    private MoneyFormatter moneyFormatter;


    /** Creates new form Desktop_MainOut
     * @param desktopController
     */
    public Desktop_MainOut(DesktopControllerHelper desktopControllerHelper) {
        this.desktopControllerHelper = desktopControllerHelper;
        desktopController = desktopControllerHelper.getDesktopController();
        initComponents();
        moneyFormatter = new MoneyFormatter();
        if (desktopController.getSessionMgr() != null)
            mgr = desktopController.getSessionMgr();
        

    }



    public void setTotals(){
        DiscountOut.setText(moneyFormatter.format(mgr.getCart().getTotalDiscount()));
        NumberLabel.setText(Integer.toString(mgr.getCart().getTotalNumItems()));
        SubTotalOut.setText(moneyFormatter.format(mgr.getCart().getSubtotal()));
        TaxOut.setText(moneyFormatter.format(mgr.getCart().getTaxAmount()));
        TotalOut.setText(moneyFormatter.format(mgr.getCart().getTotal()));
    }

//    @Override
//    public void paint(Graphics graphic){
//         super.paintAll(graphic);
//          NumberLabel.setText(Integer.toString(desktopController.getSessionMgr().getCartItemsInSession().size()));
//    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        DynamicPanel = new javax.swing.JPanel();
        TitlePanel = new javax.swing.JPanel();
        LogoLabel = new javax.swing.JLabel();
        WelcomeLabel = new javax.swing.JLabel();
        NameLabel = new javax.swing.JLabel();
        LoginButton = new javax.swing.JButton();
        ManagePanel = new javax.swing.JPanel();
        Title2Label1 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        CartPanel = new javax.swing.JPanel();
        Cart2Label = new javax.swing.JLabel();
        Cart1Label = new javax.swing.JLabel();
        ItemLabel = new javax.swing.JLabel();
        NumberLabel = new javax.swing.JLabel();
        SubTotalLabel1 = new javax.swing.JLabel();
        DiscountOut = new javax.swing.JLabel();
        SubTotalLabel = new javax.swing.JLabel();
        SubTotalOut = new javax.swing.JLabel();
        TaxOut = new javax.swing.JLabel();
        TaxLabel = new javax.swing.JLabel();
        TotalOut = new javax.swing.JLabel();
        TotalLabel = new javax.swing.JLabel();
        ManagePanel1 = new javax.swing.JPanel();
        SearchButton = new javax.swing.JButton();
        ViewCartButton = new javax.swing.JButton();
        ShopLabel = new javax.swing.JLabel();

        setBackground(new java.awt.Color(255, 255, 255));

        DynamicPanel.setBackground(new java.awt.Color(255, 255, 255));
        DynamicPanel.setPreferredSize(new java.awt.Dimension(800, 600));
        DynamicPanel.setSize(new java.awt.Dimension(800, 600));
        DynamicPanel.addContainerListener(new java.awt.event.ContainerAdapter() {
            public void componentAdded(java.awt.event.ContainerEvent evt) {
                DynamicPanelComponentAdded(evt);
            }
        });

        javax.swing.GroupLayout DynamicPanelLayout = new javax.swing.GroupLayout(DynamicPanel);
        DynamicPanel.setLayout(DynamicPanelLayout);
        DynamicPanelLayout.setHorizontalGroup(
            DynamicPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 800, Short.MAX_VALUE)
        );
        DynamicPanelLayout.setVerticalGroup(
            DynamicPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 600, Short.MAX_VALUE)
        );

        TitlePanel.setBackground(new java.awt.Color(255, 255, 255));
        TitlePanel.setSize(new java.awt.Dimension(1021, 100));

        LogoLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/DesktopGUIpackage/images/Logo.png"))); // NOI18N

        WelcomeLabel.setFont(new java.awt.Font("Tahoma", 0, 24));
        WelcomeLabel.setText("Welcome to DigiStore");

        NameLabel.setFont(new java.awt.Font("Tahoma", 0, 24));
        NameLabel.setText("Log In Now!");

        LoginButton.setFont(new java.awt.Font("Tahoma", 0, 18));
        LoginButton.setText("Log In");
        LoginButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                LoginButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout TitlePanelLayout = new javax.swing.GroupLayout(TitlePanel);
        TitlePanel.setLayout(TitlePanelLayout);
        TitlePanelLayout.setHorizontalGroup(
            TitlePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(TitlePanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(LogoLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 120, Short.MAX_VALUE)
                .addComponent(WelcomeLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(NameLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 283, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(8, 8, 8)
                .addComponent(LoginButton, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(41, 41, 41))
        );
        TitlePanelLayout.setVerticalGroup(
            TitlePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(TitlePanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(TitlePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(TitlePanelLayout.createSequentialGroup()
                        .addGap(5, 5, 5)
                        .addGroup(TitlePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(WelcomeLabel)
                            .addComponent(NameLabel)))
                    .addComponent(LogoLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(LoginButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(20, Short.MAX_VALUE))
        );

        ManagePanel.setBackground(new java.awt.Color(255, 255, 255));
        ManagePanel.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        ManagePanel.setPreferredSize(new java.awt.Dimension(178, 184));
        ManagePanel.setSize(new java.awt.Dimension(178, 184));

        Title2Label1.setFont(new java.awt.Font("Tahoma", 0, 24));
        Title2Label1.setText("Account");

        jButton1.setFont(new java.awt.Font("Tahoma", 0, 16));
        jButton1.setText("Register");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout ManagePanelLayout = new javax.swing.GroupLayout(ManagePanel);
        ManagePanel.setLayout(ManagePanelLayout);
        ManagePanelLayout.setHorizontalGroup(
            ManagePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(ManagePanelLayout.createSequentialGroup()
                .addGroup(ManagePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(ManagePanelLayout.createSequentialGroup()
                        .addGap(48, 48, 48)
                        .addComponent(Title2Label1))
                    .addGroup(ManagePanelLayout.createSequentialGroup()
                        .addGap(25, 25, 25)
                        .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(27, Short.MAX_VALUE))
        );
        ManagePanelLayout.setVerticalGroup(
            ManagePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(ManagePanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(Title2Label1)
                .addGap(45, 45, 45)
                .addComponent(jButton1)
                .addContainerGap(59, Short.MAX_VALUE))
        );

        CartPanel.setBackground(new java.awt.Color(255, 255, 255));
        CartPanel.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        CartPanel.setPreferredSize(new java.awt.Dimension(178, 212));
        CartPanel.setSize(new java.awt.Dimension(178, 212));

        Cart2Label.setFont(new java.awt.Font("Tahoma", 0, 24));
        Cart2Label.setText("Cart");

        Cart1Label.setFont(new java.awt.Font("Tahoma", 0, 24));
        Cart1Label.setText("Your");

        ItemLabel.setFont(new java.awt.Font("Tahoma", 0, 14));
        ItemLabel.setText("Items:");

        NumberLabel.setFont(new java.awt.Font("Tahoma", 0, 14));
        NumberLabel.setText("0");

        SubTotalLabel1.setFont(new java.awt.Font("Tahoma", 0, 14));
        SubTotalLabel1.setText("Discount:");

        DiscountOut.setFont(new java.awt.Font("Tahoma", 0, 14));
        DiscountOut.setText("$00.00");

        SubTotalLabel.setFont(new java.awt.Font("Tahoma", 0, 14));
        SubTotalLabel.setText("Subtotal:");

        SubTotalOut.setFont(new java.awt.Font("Tahoma", 0, 14));
        SubTotalOut.setText("$00.00");

        TaxOut.setFont(new java.awt.Font("Tahoma", 0, 14));
        TaxOut.setText("$00.00");

        TaxLabel.setFont(new java.awt.Font("Tahoma", 0, 14));
        TaxLabel.setText("Tax:");

        TotalOut.setFont(new java.awt.Font("Tahoma", 0, 14));
        TotalOut.setText("$00.00");

        TotalLabel.setFont(new java.awt.Font("Tahoma", 0, 14));
        TotalLabel.setText("Total:");

        javax.swing.GroupLayout CartPanelLayout = new javax.swing.GroupLayout(CartPanel);
        CartPanel.setLayout(CartPanelLayout);
        CartPanelLayout.setHorizontalGroup(
            CartPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(CartPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(CartPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(CartPanelLayout.createSequentialGroup()
                        .addComponent(Cart1Label, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(Cart2Label, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(55, Short.MAX_VALUE))
                    .addGroup(CartPanelLayout.createSequentialGroup()
                        .addGroup(CartPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(SubTotalLabel)
                            .addComponent(SubTotalLabel1)
                            .addComponent(TaxLabel)
                            .addComponent(TotalLabel))
                        .addGap(8, 8, 8)
                        .addGroup(CartPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(CartPanelLayout.createSequentialGroup()
                                .addComponent(DiscountOut, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addContainerGap())
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, CartPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(SubTotalOut, javax.swing.GroupLayout.PREFERRED_SIZE, 111, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, CartPanelLayout.createSequentialGroup()
                                    .addGroup(CartPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                        .addComponent(TaxOut, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 98, Short.MAX_VALUE)
                                        .addComponent(TotalOut, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGap(37, 37, 37)))))
                    .addGroup(CartPanelLayout.createSequentialGroup()
                        .addComponent(ItemLabel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(NumberLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(63, Short.MAX_VALUE))))
        );
        CartPanelLayout.setVerticalGroup(
            CartPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(CartPanelLayout.createSequentialGroup()
                .addGap(10, 10, 10)
                .addGroup(CartPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE, false)
                    .addComponent(Cart1Label)
                    .addComponent(Cart2Label))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 24, Short.MAX_VALUE)
                .addGroup(CartPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(NumberLabel)
                    .addComponent(ItemLabel))
                .addGap(18, 18, 18)
                .addGroup(CartPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(CartPanelLayout.createSequentialGroup()
                        .addComponent(DiscountOut)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(SubTotalOut, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(TaxOut))
                    .addGroup(CartPanelLayout.createSequentialGroup()
                        .addComponent(SubTotalLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(SubTotalLabel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(TaxLabel)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(CartPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(TotalOut)
                    .addComponent(TotalLabel))
                .addContainerGap())
        );

        ManagePanel1.setBackground(new java.awt.Color(255, 255, 255));
        ManagePanel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        ManagePanel1.setPreferredSize(new java.awt.Dimension(178, 217));
        ManagePanel1.setSize(new java.awt.Dimension(178, 217));

        SearchButton.setFont(new java.awt.Font("Tahoma", 0, 13));
        SearchButton.setText("Search");
        SearchButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SearchButtonActionPerformed(evt);
            }
        });

        ViewCartButton.setFont(new java.awt.Font("Tahoma", 0, 13));
        ViewCartButton.setText("View Cart");
        ViewCartButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ViewCartButtonActionPerformed(evt);
            }
        });

        ShopLabel.setFont(new java.awt.Font("Tahoma", 0, 24));
        ShopLabel.setText("Shop");

        javax.swing.GroupLayout ManagePanel1Layout = new javax.swing.GroupLayout(ManagePanel1);
        ManagePanel1.setLayout(ManagePanel1Layout);
        ManagePanel1Layout.setHorizontalGroup(
            ManagePanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(ManagePanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(ManagePanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(ManagePanel1Layout.createSequentialGroup()
                        .addGroup(ManagePanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(SearchButton, javax.swing.GroupLayout.DEFAULT_SIZE, 142, Short.MAX_VALUE)
                            .addComponent(ViewCartButton, javax.swing.GroupLayout.DEFAULT_SIZE, 142, Short.MAX_VALUE))
                        .addContainerGap())
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, ManagePanel1Layout.createSequentialGroup()
                        .addComponent(ShopLabel)
                        .addGap(61, 61, 61))))
        );
        ManagePanel1Layout.setVerticalGroup(
            ManagePanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(ManagePanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(ShopLabel)
                .addGap(30, 30, 30)
                .addComponent(SearchButton)
                .addGap(32, 32, 32)
                .addComponent(ViewCartButton)
                .addContainerGap(46, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(TitlePanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(26, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(CartPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 178, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(ManagePanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(ManagePanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(DynamicPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(TitlePanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(ManagePanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(ManagePanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(CartPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 212, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(DynamicPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(23, 23, 23))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
        desktopControllerHelper.RegisterationScreen();

    }//GEN-LAST:event_jButton1ActionPerformed

    private void LoginButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_LoginButtonActionPerformed
        // TODO add your handling code here:
       //LoginButton.setVisible(false);
        desktopControllerHelper.LogInScreen();
    }//GEN-LAST:event_LoginButtonActionPerformed

    private void ViewCartButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ViewCartButtonActionPerformed
        // TODO add your handling code here:
        desktopControllerHelper.cartScreen();
    }//GEN-LAST:event_ViewCartButtonActionPerformed

    private void DynamicPanelComponentAdded(java.awt.event.ContainerEvent evt) {//GEN-FIRST:event_DynamicPanelComponentAdded
        // TODO add your handling code here:
        // NumberLabel.setText(Integer.toString(desktopController.getSessionMgr().getCartItemsInSession().size()));

      int qty = 0;
        int numItems = 0;
        if (mgr != null) {

            List<Item> itemList = mgr.getCartItemsInSession();
            if (itemList != null) {
                numItems = itemList.size();
                qty = 0;
                for (int i = 0; i < numItems; i++) {
                    qty += itemList.get(i).getQty();
                }
            }

            System.out.println("num item ** "+ qty * numItems);
            if(qty * numItems != 0)
            NumberLabel.setText(Integer.toString(qty * numItems));
        } 
    }//GEN-LAST:event_DynamicPanelComponentAdded

    private void SearchButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SearchButtonActionPerformed
        desktopControllerHelper.SearchScreen();
    }//GEN-LAST:event_SearchButtonActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel Cart1Label;
    private javax.swing.JLabel Cart2Label;
    private javax.swing.JPanel CartPanel;
    private javax.swing.JLabel DiscountOut;
    private javax.swing.JPanel DynamicPanel;
    private javax.swing.JLabel ItemLabel;
    private javax.swing.JButton LoginButton;
    private javax.swing.JLabel LogoLabel;
    private javax.swing.JPanel ManagePanel;
    private javax.swing.JPanel ManagePanel1;
    private javax.swing.JLabel NameLabel;
    private javax.swing.JLabel NumberLabel;
    private javax.swing.JButton SearchButton;
    private javax.swing.JLabel ShopLabel;
    private javax.swing.JLabel SubTotalLabel;
    private javax.swing.JLabel SubTotalLabel1;
    private javax.swing.JLabel SubTotalOut;
    private javax.swing.JLabel TaxLabel;
    private javax.swing.JLabel TaxOut;
    private javax.swing.JLabel Title2Label1;
    private javax.swing.JPanel TitlePanel;
    private javax.swing.JLabel TotalLabel;
    private javax.swing.JLabel TotalOut;
    private javax.swing.JButton ViewCartButton;
    private javax.swing.JLabel WelcomeLabel;
    private javax.swing.JButton jButton1;
    // End of variables declaration//GEN-END:variables

    void changeScreen(JPanel panel) {
        DynamicPanel.removeAll();
        DynamicPanel.add(panel);
        DynamicPanel.validate();
        DynamicPanel.repaint();
//        NumberLabel.setText(desktopController.getNumItemsInCart());
//        SubTotalOut.setText(moneyFormatter.format(desktopController.getCart().getSubtotal()));
//        TaxOut.setText(moneyFormatter.format(desktopController.getCart().getTaxAmount()));
//        TotalOut.setText(moneyFormatter.format(desktopController.getCart().getTotal()));
    }
}
